<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../../back-common.jsp"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
        <script src="${contextPath}/resources/common/js/jquery.validate.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" media="screen" href="${contextPath}/resources/common/css/errorform.css" />
                <link rel="stylesheet" href="<ls:templateResource item='/resources/plugins/kindeditor/themes/default/default.css'/>" />
		 <link rel="stylesheet" href="<ls:templateResource item='/resources/plugins/kindeditor/plugins/code/prettify.css'/>" />
		 <script charset="utf-8" src="<ls:templateResource item='/resources/plugins/kindeditor/kindeditor-min.js'/>"></script>
		 <script charset="utf-8" src="<ls:templateResource item='/resources/plugins/kindeditor/lang/zh_CN.js'/>"></script>
		 <script charset="utf-8" src="<ls:templateResource item='/resources/plugins/kindeditor/plugins/code/prettify.js'/>"></script>
        <script language="javascript">
    $.validator.setDefaults({
    });

    $(document).ready(function() {
    jQuery("#form1").validate({
    	ignore:"",
        rules: {
            title: {
		        required: true
		    },
		    email: {
		    	 required: true
		    },
		    mobile: {
		        required: true
		    },
		   userName: {
		   		required: true
		   },
		   text: {
		   		required: true	
		   }
        },
        messages: {
            title: {
                required: "标题不能为空"
            },
            email: {
            	required: "email不能为空"
            },
            mobile: {
                required: "手机不能为空"
            },
            userName: {
            	required: "用户名不能为空"
            },
            text: {
            	required: "内容为空"
            }
        }
    });
});
</script>
      <form:form   action="${contextPath}/admin/sendmessage/send" id="form1" method="post">
      	<input type="hidden" id="type" name="type" value="${type}">
        <table class="${tableclass}" style="width: 100%">
	    <thead>
	    	<tr><th><strong class="am-text-primary am-text-lg">权限管理</strong> /  <c:if test="${type == 1}">发送站内信</c:if>
	    	<c:if test="${type == 2}">发送邮件</c:if>
	    	<c:if test="${type == 3}">发送短信</c:if>
	    	</th></tr>
	    </thead>
	    </table>
      
    <div align="center">
     <table  align="center" class="${tableclass}" id="col1">
     <c:if test="${type!=3}">
	      <tr>
	        <td>
	          <div align="center">标题 <font color="ff0000">*</font></div>
	       </td>
	        <td>
	           <input type="text" name="title" id="title" value="" size="50"/>
	        </td>
	      </tr>
      </c:if>
      <c:if test="${type == 3 }">
	      <tr>
	        <td>
	          <div align="center">手机号码<font color="ff0000">*</font></div>
	       </td>
	        <td>
	           <input type="text" name="mobile" id="mobile" value="${userDetail.userMobile}" maxlength="30" readonly="readonly"/>
	        </td>
	      </tr>
      </c:if>
      <c:if test="${type == 2 }">
	      <tr>
	        <td>
	          <div align="center">Email</div>
	       </td>
	        <td>
	        	<c:choose>
	        		<c:when test="${not empty userDetail.userMail}">
	        			<lable>${userDetail.userMail}</lable>
	        		</c:when>
	        		<c:otherwise>
	        			<lable>用户未绑定邮箱</lable>
	        		</c:otherwise>
	        	</c:choose>
	           <%-- <input type="text" name="email" id="email" value="${userDetail.userMail}" maxlength="30" readonly="readonly"/> --%>
	        </td>
	      </tr>
      </c:if>
	       <tr>
	        <td>
	          <div align="center">用户名 <font color="ff0000">*</font></div>
	       </td>
	        <td>
	           <input type="text" name="userName" id="userName" value="${userDetail.userName}" maxlength="30" readonly="readonly"/>
	        </td>
	      </tr>
        <tr>
        <td>
          <div align="center">内容 <font color="ff0000">*</font></div>
       </td>
        <td>
        	<c:if test="${type==2}">
        		<textarea name="text" id="text" cols="100" rows="8" style="width:100%;height:400px;visibility:hidden;"></textarea> 
        	</c:if>
        	<c:if test="${type!=2}">
           		<input type="text" name="text" id="text" value="" size="70"/>
           </c:if>
        </td>
      </tr>
       <tr>
           <td colspan="2">
               <div align="center">
    						<input class="${btnclass}" type="submit" value="提交" />
                   	<input class="${btnclass}" type="reset" value="重置" />
                   	<input class="${btnclass}" type="button" value="返回"
                       onclick="window.history.go(-1)" />
               </div>
           </td>
       </tr>
   </table>
  </div>
 </form:form>
<script type="text/javascript">
	$(function(){
			var msg="${msg}";
			if(msg!=""){
				art.dialog.tips(msg);
				window.location.href="${contextPath}/admin/system/userDetail/query";
			}
			KindEditor.options.filterMode=false;
    		KindEditor.create('textarea[name="text"]', {
				cssPath : '${contextPath}/resources/plugins/kindeditor/plugins/code/prettify.css',
				uploadJson : '${contextPath}/editor/uploadJson/upload;jsessionid=${cookie.JSESSIONID.value}',
				fileManagerJson : '${contextPath}/editor/uploadJson/fileManager',
				allowFileManager : true,
				afterBlur:function(){this.sync();},
				width : '100%',
				height:'400px',
				afterCreate : function() {
					var self = this;
					KindEditor.ctrl(document, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
					KindEditor.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
				}
			});
    	});
	
</script>

